package cn.jy.careuplusdoctor.adapter;

import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import cn.jy.careuplusdoctor.R;
import cn.jy.careuplusdoctor.entity.Subject;

public class SectionOfficeListAdapter extends BaseAdapter{
		private Context context;
		private List<Subject> list ;
		public SectionOfficeListAdapter(Context context) {
			this.context = context;
			list = new ArrayList<Subject>() ;
		}

		public List<Subject> getList() {
			return list;
		}

		public void setList(List<Subject> list) {
			this.list = list;
		}

		@Override
		public int getCount() {
			return list.size();
		}

		@Override
		public Object getItem(int position) {
			return list.get(position);
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			Holder _holder;
			if(convertView==null){
				convertView = LayoutInflater.from(context).inflate(R.layout.item_hospital, null);
				_holder = new Holder();
				_holder.txt_itme_hospital = (TextView)convertView.findViewById(R.id.txt_itme_hospital);
			} else {
				_holder = (Holder) convertView.getTag();
			}
			_holder.txt_itme_hospital.setText(list.get(position).getSubjectName());
			return convertView;
		}
		public class Holder{
			private TextView txt_itme_hospital;
		}
		public void addAll(List<Subject> list) {
			if (list!= null) {
				this.list.clear();
				this.list.addAll(list);
				notifyDataSetChanged();
			}
		}
}
